<?php

// @formatter:off
/**
 * @file WCActionController.php
 *
 * @author Alejandro Dario Simi
 * @date $Date: 2014-05-04 01:33:52 +0000 (Sun, 04 May 2014) $
 *
 * $Id: WCActionController.php 111 2014-05-04 01:33:52Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/includes/mvc/WCActionController.php $
 */
// @formatter:on

class WCActionController extends WCViewController {
	//
	// Protected properties.
	protected $_useLayout = true;
	protected $_useSkin = true;
	//
	// Magic methods.
	public function __construct() {
		parent::__construct();

		$this->_id = $this->_manager->actionId($this->name(), "A", true);
		$this->_selector["id"] = $this->id();
	}
	public function check() {
		$check = parent::check();

		if($check == WC_HTTPERROR_OK) {
			global $wcProfile;
			global $wcGroup;

			if(in_array("group", $this->_requiredParams)) {
				if($check == WC_HTTPERROR_OK && (!$wcGroup || !$wcGroup->ok())) {
					global $errno;
					global $error;

					$check = WC_HTTPERROR_BAD_REQUEST;
					$errno = $check;
					$error = "Invalid group";
				}
				if($check == WC_HTTPERROR_OK && !$wcProfile->grantedGroup($wcGroup)) {
					global $errno;
					global $error;

					$check = WC_HTTPERROR_FORBIDDEN;
					$errno = $check;
					$error = "You don't have enough priviliges";
				}
			}
		}

		return $check;
	}
	//
	// Public methods.
	public function skin() {
		return $this->_skin;
	}
	public function useLayout() {
		return $this->_useLayout;
	}
	public function useSkin() {
		return $this->_useSkin;
	}
}
